
**** Required packages
ssc install regsave, replace
ssc install statastates, replace

***** INCLUDED DATASETS
* "analytic sample public with party BOTH WAVES.dta": just the public, with partisanship
* "analytic sample public and elected BOTH WAVES.dta": both the public and elected, without partisanship
* "analytic sample public and elected with gender BOTH WAVES.dta": both samples, with gender
* "public discrimination by state.csv": model output for Figure 5
* "elected discrimination by state.csv": model output for Figure 5
* "interaction discrimination by state.csv": model output for Figure 5
* "study_comparison_with_meta.csv": for the meta analysis of audits on elected officials
* "emailcoverageclean.csv": data on email coverage by state
* "samplesize.csv": data on sample size across states among the public
* "samplesizeelected.csv": data on sample size across states among the public
* "predicting_state_diffs_public_elected.dta": state level measures with difference between public and elected officials across states
* "predicting_public_discrim.dta": state level measures with discrimination among public across states
* "predicting_elected_discrim": state level measures with discrimination among elected officials across states
* "correlations.csv": correlation coefficients for predicting_state_diffs_public_elected
* "correlations public.csv" correlation coefficients for predicting_public_discrim
* "correlations elected.csv" correlation coefficients for predicting_elected_discrim
* "state populations.dta": state-level populations 
* "state_numbers.dta": state abbreviations
* "final_name_match_public_sample.dta": file that contains markers of having a neighbor with one of our treatment names
* "Racial Animus by State.dta", "raceiatdat_state_just_white.dta", "Racial Animus by State.csv": other measures of racial discrimination by state

cd "" // set your working directory here and put all of the above datasets here (remember to set the working directory in the R script too)

*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************** IN TEXT  ************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************


****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE 1 - Left Panel **************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE

*STEP 1.) RUN REGRESSION MODELS BELOW
 use "analytic sample public and elected BOTH WAVES.dta", clear

  reghdfe  responded blacktr if elected_official==0, absorb(unique_id_pooled) // model for the public
  regsave blacktr using "overall_effects_concordance.dta", detail(all) addlabel(group, Public) replace // stores results for figure
sum responded if blacktr==0 & e(sample)==1 & elected_official==0 // gives you the base rate of the estimation sample
	
 reghdfe  responded blacktr if elected_official==1, absorb(unique_id_pooled) // model for elected officials
 regsave blacktr using "overall_effects_concordance.dta", detail(all) addlabel(group, Elected Officials) append // stores results for figure 
 sum responded if blacktr==0 & e(sample)==1 & elected_official==1	// gives you the base rate of the estimation sample
  
  *STEP 2.) SCALE RELATIVE TO BASE RATE
 use  "overall_effects_concordance.dta", clear // calls the stored regression output
 
 capture drop  coef_base stderr_base
 gen coef_base=.
  gen stderr_base=.

 replace coef_base=coef/.016028 if group=="Public" // scales coefficient 
  replace stderr_base=stderr/.016028 if group=="Public" // scales standard errors

  replace coef_base=coef/.0415679 if group=="Elected Officials" // scales coefficient
  replace stderr_base=stderr/.0415679 if group=="Elected Officials"
 
  capture drop model_num
  gen model_num=_n // for the ordering in the graph
    
 gen ub95= coef_base+1.96*stderr_base // 95% CIs
gen lb95= coef_base-1.96*stderr_base
  
saveold  "overall_effects_concordance_no_interact.dta", version(12) replace // exports scaled results to be called into R for the left panel of FIGURE 2

// go to "Audit the Public Figures Replication File.R" to create the left panel of Figure 2

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE 1 - Right Panel *************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

 ***Public
 use "analytic sample public and elected BOTH WAVES.dta", clear

 keep if elected_official==0
 
set seed 123456789
permute responded "reg responded blacktr" _b, reps(1000) saving("public permute") replace // if this file--i.e. "public permute.dta"--already exists, you may have to delete it first to re-run this command.

*** Elected Officials
 use "analytic sample public and elected BOTH WAVES.dta", clear
 
 keep if elected_official==1
 
set seed 123456789
permute responded "reg responded blacktr" _b, reps(1000) saving("elected officials permute") replace // if this file--i.e. "elected officials permute.dta"--already exists, you may have to delete it first to re-run this command.

 *** Cleaning the permutation tests up
 use "public permute.dta", clear
 
 replace b_blacktr = b_blacktr/.016028
 
 gen larger=1 if b_blacktr<-.096581
 replace larger=0 if b_blacktr>=-.096581
 tab larger // 0%
 
  saveold "public permute clean.dta", replace version(12)
  
   use "elected officials permute.dta", clear
 
 replace b_blacktr = b_blacktr/.0415679
 
 gen larger=1 if b_blacktr<-.0593825
 replace larger=0 if b_blacktr>=-.0593825
 tab larger // 4.5%
 
  saveold "elected officials permute clean.dta", replace version(12)
  
  // go to "Audit the Public Figures Replication File.R" to create the right panel of Figure 2
  
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE 2  **************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
  
 *** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE 
  
 *STEP 1.) RUN REGRESSION MODELS BELOW
   use "analytic sample public and elected BOTH WAVES.dta", clear

   drop if elected==1
   rename unique_id_pooled dt_regid
   
 areg  responded blacktr, absorb(dt_regid)
 sum responded if blacktr==0 & e(sample)==1
 regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Pooled Sample) replace 

 areg  responded blacktr if white==1, absorb(dt_regid) // among white
  sum responded if blacktr==0 & e(sample)==1 // for scaling effects
regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Whites) append 

 areg  responded blacktr if black==1, absorb(dt_regid) // among black
   sum responded if blacktr==0 & e(sample)==1 // for scaling effects
regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Blacks) append

 areg  responded blacktr if asian==1, absorb(dt_regid) // among asian
   sum responded if blacktr==0 & e(sample)==1 // for scaling effects
regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Asians) append

 areg  responded blacktr if hispanic==1, absorb(dt_regid) // among hispanic
  sum responded if blacktr==0 & e(sample)==1 // for scaling effects
regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Hispanics) append

 areg  responded blacktr if white==0 & black==0, absorb(dt_regid) // among non white & non black
  sum responded if blacktr==0 & e(sample)==1 // for scaling effects
regsave blacktr using "overall_effects_by_recipient_race.dta", detail(all) addlabel(group, Hispanics & Asians) append	 
 
 
 *STEP 2.) SCALE RELATIVE TO BASE RATE
use "overall_effects_by_recipient_race.dta", clear
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.016028 if group=="Pooled Sample"
replace coef_base=coef/.0175594  if group=="Whites"
replace coef_base=coef/.009906  if group=="Blacks"
replace coef_base=coef/.0128277 if group=="Asians"
replace coef_base=coef/.0121604 if group=="Hispanics"
replace coef_base=coef/.0138406 if group=="Hispanics & Asians"

replace stderr_base=stderr/.016028 if group=="Pooled Sample"
replace stderr_base=stderr/.0175594  if group=="Whites"
replace stderr_base=stderr/.009906  if group=="Blacks"
replace stderr_base=stderr/.0128277 if group=="Asians"
replace stderr_base=stderr/.0121604 if group=="Hispanics"
replace stderr_base=stderr/.0138406 if group=="Hispanics & Asians"

replace group="Hispanics, Asians, Other" if group=="Hispanics & Asians"

gen model_num=.
replace model_num=1 in 6
replace model_num=2 in 5
replace model_num=3 in 4
replace model_num=4 in 3
replace model_num=5 in 2
replace model_num=6 in 1

saveold "overall_effects_by_recipient_race_old.dta", replace version(12)

  // go to "Audit the Public Figures Replication File.R" to create Figure 3

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE 3  **************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE
  
*1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS

    use "analytic sample public with party BOTH WAVES.dta", clear
  
 areg  responded blacktr if modeled_republican==1, absorb(state_encode)  // Republicans
	sum responded if blacktr==0 & e(sample)==1 //
	regsave blacktr using "by_political_party.dta", detail(all) addlabel(subgroup, Republicans) replace 

 areg  responded blacktr if modeled_democrat==1, absorb(state_encode)   // Democrats
	sum responded if blacktr==0 & e(sample)==1 // 
	regsave blacktr using "by_political_party.dta", detail(all) addlabel(subgroup, Democrats) append 

 areg  responded blacktr if modeled_independent==1, absorb(state_encode)   // independent
sum responded if blacktr==0 & e(sample)==1 //
 regsave blacktr using "by_political_party.dta", detail(all) addlabel(subgroup, Independents) append 
  
  reg  responded blacktr##modeled_republican_v_democrat i.state_encode   // republicans more discriminatory than democrats
  reg  responded blacktr##modeled_republican_v_independent i.state_encode   // republicans more discriminatory than independents, but marginally not significant
  reg  responded blacktr##  modeled_democrat_v_independent i.state_encode   // independents more discriminatory than democrats, but marginally not significant 
  
*2.) SCALE RELATIVE TO BASE RATE
	
use "by_political_party.dta", clear
	
capture drop coef_base stderr_base model_num
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.0203984  if subgroup=="Republicans"
replace coef_base=coef/.0155299  if subgroup=="Democrats"
replace coef_base=coef/.012499  if subgroup=="Independents"

replace stderr_base=stderr/.0203984  if subgroup=="Republicans"
replace stderr_base=stderr/.0155299  if subgroup=="Democrats"
replace stderr_base=stderr/.012499  if subgroup=="Independents"

gen model_num=_n

saveold "by_political_party.dta", version(12) replace

  // go to "Audit the Public Figures Replication File.R" to create Figure 4

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE 4  **************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
******** PANEL 1: THE PUBLIC    
use "analytic sample public and elected BOTH WAVES.dta", clear
	 
reg  responded blacktr##ibn.state_encode if elected_official==0, nocon baselevels 
margins r.blacktr, over(state_encode)
*COPY AND PASTE MARGINS OUTPUT INTO SPREADSHEET ENTITLED "public discrimination by state.csv" (provided)
	 
import delimited "public discrimination by state.csv", encoding(UTF-8) clear 
statastates, a(state_abbrev)
rename state_name region 
replace region=lower(region)
drop if _merge==2
drop _merge
	 
gsort - coef_base
gen num=_n
saveold "public discrimination by state.dta", version(12) replace 

******** PANEL 2: THE ELECTED OFFICIALS    
use "analytic sample public and elected BOTH WAVES.dta", clear
	 
reg  responded blacktr##ibn.state_encode if elected_official==1, nocon baselevels 
margins r.blacktr, over(state_encode)
*COPY AND PASTE MARGINS OUTPUT INTO SPREADSHEET ENTITLED "elected discrimination by state.csv" (provided)
	 
import delimited "elected discrimination by state.csv", encoding(UTF-8) clear 
statastates, a(state_abbrev)
rename state_name region 
replace region=lower(region)
drop if _merge==2
drop _merge
saveold "elected discrimination by state.dta", version(12) replace 
	 
******** PANEL 3: THE INTERACTION    
use "analytic sample public and elected BOTH WAVES.dta", clear
	 
reg  responded blacktr##ibn.state_encode##i.elected_official, nocon baselevels 
margins r.blacktr#r.elected_official, over(state_encode)
*COPY AND PASTE MARGINS OUTPUT INTO SPREADSHEET ENTITLED "interaction discrimination by state.csv" (provided)
	 
import delimited "interaction discrimination by state.csv", encoding(UTF-8) clear 
statastates, a(state_abbrev)
rename state_name region 
replace region=lower(region)
drop if _merge==2
drop _merge
	 
gen t_stat=coef/se
	 
gen interaction=1
saveold "interaction discrimination by state.dta", version(12) replace 

  // go to "Audit the Public Figures Replication File.R" to create Figure 5


*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************** SUPPORTING INFORMATION  *********************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************  
  
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S1  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
// see "Audit the Public Figures Replication File.R" for the code that made this figure

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S2  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
// see "Audit the Public Figures Replication File.R" for the code that made this figure

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S3  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
// see "Audit the Public Figures Replication File.R" for the code that made this figure

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S4/S5  **********************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
// Replicated and Reproduced from Crabtree (2019)

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S6  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE
  
*1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS

use "analytic sample public and elected BOTH WAVES.dta", clear

 reghdfe  responded blacktr if elected_official==0 , absorb(unique_id_pooled)
 regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, None) replace 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Andre Jefferson", absorb(unique_id_pooled)
   regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Andre Jefferson) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Christopher Schmidt", absorb(unique_id_pooled)
    regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Christopher Schmidt) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Darryl Jefferson", absorb(unique_id_pooled)
     regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Darryl Jefferson) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Darryl Washington", absorb(unique_id_pooled)
      regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Darryl Washington) append 
 
 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Dominique Washington", absorb(unique_id_pooled)
       regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Dominique Washington) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Matthew Roberts", absorb(unique_id_pooled)
        regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Matthew Roberts) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Nicholas Austin", absorb(unique_id_pooled)
         regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Nicholas Austin) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Ryan Thompson", absorb(unique_id_pooled)
          regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Ryan Thompson) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Willie Washington", absorb(unique_id_pooled)
           regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Willie Washington) append 

 reghdfe  responded blacktr if elected_official==0 & externaldatareference~="Zachary Fitzpatrick", absorb(unique_id_pooled)
           regsave blacktr using "jacknife names.dta", detail(all) addlabel(group, Public, Name, Zachary Fitzpatrick) append 

* 2.) SCALE RELATIVE TO BASE RATE
use "jacknife names.dta", clear
 
 gen coef_base=coef/.016028
 gen stderr_base=stderr/.016028
 
gen white=1 if Name=="Zachary Fitzpatrick" | Name=="Ryan Thompson" | Name=="Nicholas Austin" | Name=="Matthew Roberts" | Name=="Christopher Schmidt"
replace white=0 if white==.
replace white=2 if Name=="None"

 gen num=10 if Name=="Christopher Schmidt" 
replace num=9 if Name=="Matthew Roberts"
replace num=8 if Name=="Nicholas Austin"
replace num=7 if Name=="Ryan Thompson" 
replace num=6 if Name=="Zachary Fitzpatrick" 
replace num=5 if Name=="Andre Jefferson" 
replace num=4 if Name=="Darryl Jefferson" 
replace num=3 if Name=="Darryl Washington"
replace num=2 if Name=="Dominique Washington" 
replace num=1 if Name=="Willie Washington"

 saveold "jacknife names cleaned.dta", version(12) replace
   
   // go to "Audit the Public Figures Replication File.R" to create Figure 
 
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S7  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE
  
*1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
use "analytic sample public and elected BOTH WAVES.dta", clear

 reghdfe  responded blacktr if elected_official==1 , absorb(unique_id_pooled)
  regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, None) replace 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Andre Jefferson", absorb(unique_id_pooled)
   regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Andre Jefferson) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Christopher Schmidt", absorb(unique_id_pooled)
    regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Christopher Schmidt) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Darryl Jefferson", absorb(unique_id_pooled)
     regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Darryl Jefferson) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Darryl Washington", absorb(unique_id_pooled)
      regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Darryl Washington) append 
 
 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Dominique Washington", absorb(unique_id_pooled)
       regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Dominique Washington) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Matthew Roberts", absorb(unique_id_pooled)
        regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Matthew Roberts) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Nicholas Austin", absorb(unique_id_pooled)
         regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Nicholas Austin) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Ryan Thompson", absorb(unique_id_pooled)
          regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Ryan Thompson) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Willie Washington", absorb(unique_id_pooled)
           regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Willie Washington) append 

 reghdfe  responded blacktr if elected_official==1 & externaldatareference~="Zachary Fitzpatrick", absorb(unique_id_pooled)
           regsave blacktr using "jacknife names elected.dta", detail(all) addlabel(group, Elected, Name, Zachary Fitzpatrick) append 
		   
* 2.) SCALE RELATIVE TO BASE RATE
 use "jacknife names elected.dta", clear
 
 gen coef_base=coef/.0416348  
 gen stderr_base=stderr/.0416348  
 
gen white=1 if Name=="Zachary Fitzpatrick" | Name=="Ryan Thompson" | Name=="Nicholas Austin" | Name=="Matthew Roberts" | Name=="Christopher Schmidt"
replace white=0 if white==.
replace white=2 if Name=="None"

 gen num=10 if Name=="Christopher Schmidt" 
replace num=9 if Name=="Matthew Roberts"
replace num=8 if Name=="Nicholas Austin"
replace num=7 if Name=="Ryan Thompson" 
replace num=6 if Name=="Zachary Fitzpatrick" 
replace num=5 if Name=="Andre Jefferson" 
replace num=4 if Name=="Darryl Jefferson" 
replace num=3 if Name=="Darryl Washington"
replace num=2 if Name=="Dominique Washington" 
replace num=1 if Name=="Willie Washington"

 saveold "jacknife names elected cleaned.dta", version(12) replace
 
    // go to "Audit the Public Figures Replication File.R" to create Figure 

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S8  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE
  
*1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
use "analytic sample public and elected BOTH WAVES.dta", clear
 tab externaldatareference, gen(names_)
 
  reghdfe  responded names_1 names_3 names_4 names_5 names_9 if elected_official==0 , absorb(unique_id_pooled) 
  sum responded if blacktr==0 &  e(sample)==1 //  .016028
 regsave names_1 names_3 names_4 names_5 names_9 using "effects by names.dta", detail(all) addlabel(group, Public) replace 
  
  reghdfe  responded names_2 names_6 names_7 names_8 names_10 if elected_official==0 , absorb(unique_id_pooled) 
  sum responded if blacktr==1 &  e(sample)==1 // .01448
 regsave names_2 names_6 names_7 names_8 names_10 using "effects by names.dta", detail(all) addlabel(group, Public) append 

* 2.) SCALE RELATIVE TO BASE RATE
 use "effects by names.dta", clear

 gen white=1 if var=="names_2" | var=="names_6" | var=="names_7" | var=="names_8" | var=="names_10"
replace white=0 if white==.

replace var="Christopher Schmidt" if var=="names_2"
replace var="Matthew Roberts" if var=="names_6"
replace var="Nicholas Austin" if var=="names_7"
replace var="Ryan Thompson" if var=="names_8"
replace var="Zachary Fitzpatrick" if var=="names_10"

replace var="Andre Jefferson" if var=="names_1"
replace var="Darryl Jefferson" if var=="names_3"
replace var="Darryl Washington" if var=="names_4"
replace var="Dominique Washington" if var=="names_5"
replace var="Willie Washington" if var=="names_9"

 gen coef_base=coef/.016028
 gen stderr_base=stderr/.016028
  
 gen num=10 if var=="Christopher Schmidt" 
replace num=9 if var=="Matthew Roberts"
replace num=8 if var=="Nicholas Austin"
replace num=7 if var=="Ryan Thompson" 
replace num=6 if var=="Zachary Fitzpatrick" 
replace num=5 if var=="Andre Jefferson" 
replace num=4 if var=="Darryl Jefferson" 
replace num=3 if var=="Darryl Washington"
replace num=2 if var=="Dominique Washington" 
replace num=1 if var=="Willie Washington"

saveold "effects by names cleaned.dta", version(12) replace

   // go to "Audit the Public Figures Replication File.R" to create Figure 

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S9  *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
*** TAKES 2 STEPS:
*** 1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
*** 2.) SCALE RELATIVE TO BASE RATE
  
*1.) RUN REGRESSION MODELS BELOW, REGSAVE WILL STORE THE MODEL RESULTS
use "analytic sample public and elected BOTH WAVES.dta", clear
 tab externaldatareference, gen(names_)
 
reghdfe  responded names_1 names_3 names_4 names_5 names_9 if elected_official==1 , absorb(unique_id_pooled) 
sum responded if blacktr==0 &  e(sample)==1 //  .016028
regsave names_1 names_3 names_4 names_5 names_9 using "effects by names elected.dta", detail(all) addlabel(group, Elected) replace 
  
reghdfe  responded names_2 names_6 names_7 names_8 names_10 if elected_official==1 , absorb(unique_id_pooled) 
sum responded if blacktr==1 &  e(sample)==1 // .01448
regsave names_2 names_6 names_7 names_8 names_10 using "effects by names elected.dta", detail(all) addlabel(group, Elected) append  
   
* 2.) SCALE RELATIVE TO BASE RATE
 use "effects by names elected.dta", clear

 gen white=1 if var=="names_2" | var=="names_6" | var=="names_7" | var=="names_8" | var=="names_10"
replace white=0 if white==.

replace var="Christopher Schmidt" if var=="names_2"
replace var="Matthew Roberts" if var=="names_6"
replace var="Nicholas Austin" if var=="names_7"
replace var="Ryan Thompson" if var=="names_8"
replace var="Zachary Fitzpatrick" if var=="names_10"

replace var="Andre Jefferson" if var=="names_1"
replace var="Darryl Jefferson" if var=="names_3"
replace var="Darryl Washington" if var=="names_4"
replace var="Dominique Washington" if var=="names_5"
replace var="Willie Washington" if var=="names_9"

 gen coef_base=coef/.0416348  
 gen stderr_base=stderr/.0416348  
 
 gen num=10 if var=="Christopher Schmidt" 
replace num=9 if var=="Matthew Roberts"
replace num=8 if var=="Nicholas Austin"
replace num=7 if var=="Ryan Thompson" 
replace num=6 if var=="Zachary Fitzpatrick" 
replace num=5 if var=="Andre Jefferson" 
replace num=4 if var=="Darryl Jefferson" 
replace num=3 if var=="Darryl Washington"
replace num=2 if var=="Dominique Washington" 
replace num=1 if var=="Willie Washington"

saveold "effects by names elected cleaned.dta", version(12) replace
   
   // go to "Audit the Public Figures Replication File.R" to create Figure 
   
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S10  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
    
   use "analytic sample public and elected with gender BOTH WAVES.dta", clear
 
  gen blacktr=1 if whitetrw2==0
 replace blacktr=0 if  whitetrw2==1
 
 tab state , gen(st_)

 regress asian blacktr if elected==0
  regsave blacktr using "public covariate balance", detail(all) addlabel(group, Public, variable, asian) replace 


foreach var in  black hispanic white female st_1 st_2 st_3 st_4 st_5 st_6 st_7 st_8 st_9 st_10 st_11 st_12 st_13 st_14 st_15 st_16 st_17 st_18 st_19 st_20 st_21 st_22 st_23 st_24 st_25 st_26 st_27 st_28 st_29 st_30 st_31 st_32 st_33 st_34 st_35 st_36 st_37 st_38 st_39 st_40 st_41 st_42 st_43 st_44 st_45 st_46 st_47 st_48 st_49 st_50 south {

regress `var' blacktr if elected==0
  regsave blacktr using "public covariate balance", detail(all) addlabel(group, Public, variable, `var') append 
}  

use "public covariate balance", clear
gen num=_n
saveold "public covariate balance", version(12) replace
   
      // go to "Audit the Public Figures Replication File.R" to create Figure 
   
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S11  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
   
use "analytic sample public and elected with gender BOTH WAVES.dta", clear
 
  gen blacktr=1 if whitetrw2==0
 replace blacktr=0 if  whitetrw2==1
 tab state , gen(st_)

 regress asian blacktr if elected==1
  regsave blacktr using "elected covariate balance", detail(all) addlabel(group, Elected, variable, asian) replace 


foreach var in   black hispanic white female st_1 st_2 st_3 st_4 st_5 st_6 st_7 st_8 st_9 st_10 st_11 st_12 st_13 st_14 st_15 st_16 st_17 st_18 st_19 st_20 st_21 st_22 st_23 st_24 st_25 st_26 st_27 st_28 st_29 st_30 st_31 st_32 st_33 st_34 st_35 st_36 st_37 st_38 st_39 st_40 st_41 st_42 st_43 st_44 st_45 st_46 st_47 st_48 st_49 st_50 south {

regress `var' blacktr if elected==1
  regsave blacktr using "elected covariate balance", detail(all) addlabel(group, Elected, variable, `var') append 
}
   
use "elected covariate balance", clear
gen num=_n
saveold "elected covariate balance", version(12) replace

   // go to "Audit the Public Figures Replication File.R" to create Figure 

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S12  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "analytic sample public and elected with gender BOTH WAVES.dta", clear

  gen blacktr=1 if whitetrw2==0
 replace blacktr=0 if  whitetrw2==1
 tab state , gen(st_)

 regress asian blacktr
  regsave blacktr using "pooled covariate balance", detail(all) addlabel(group, Pooled, variable, asian) replace 

foreach var in  black hispanic white female st_1 st_2 st_3 st_4 st_5 st_6 st_7 st_8 st_9 st_10 st_11 st_12 st_13 st_14 st_15 st_16 st_17 st_18 st_19 st_20 st_21 st_22 st_23 st_24 st_25 st_26 st_27 st_28 st_29 st_30 st_31 st_32 st_33 st_34 st_35 st_36 st_37 st_38 st_39 st_40 st_41 st_42 st_43 st_44 st_45 st_46 st_47 st_48 st_49 st_50 south {

regress `var' blacktr
  regsave blacktr using "pooled covariate balance", detail(all) addlabel(group, Pooled, variable, `var') append 
}

use "pooled covariate balance", clear
gen num=_n
saveold "pooled covariate balance", version(12) replace
   
      // go to "Audit the Public Figures Replication File.R" to create Figure 
	  
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S13  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
   
use "predicting_state_diffs_public_elected.dta", clear

foreach var in  poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt {

destring `var', replace

}

replace cons_fossil = subinstr(cons_fossil,",","",.)
destring cons_fossil, replace
replace cons_renewable = subinstr(cons_renewable,",","",.)
destring cons_renewable, replace

pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig 

pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig b

corr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt

// COPY INTO SPREADSHEET "correlations.csv"
   // go to "Audit the Public Figures Replication File.R" to create Figure 

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S14  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "predicting_public_discrim.dta", clear

foreach var in  poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt {

destring `var', replace

}

replace cons_fossil = subinstr(cons_fossil,",","",.)
destring cons_fossil, replace
replace cons_renewable = subinstr(cons_renewable,",","",.)
destring cons_renewable, replace


pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig 

pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig b

corr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt

  // COPY INTO SPREADSHEET "correlations public.csv"
   // go to "Audit the Public Figures Replication File.R" to create Figure 

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S15  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "predicting_elected_discrim", clear

foreach var in  poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt {

destring `var', replace

}

replace cons_fossil = subinstr(cons_fossil,",","",.)
destring cons_fossil, replace
replace cons_renewable = subinstr(cons_renewable,",","",.)
destring cons_renewable, replace


pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig 

pwcorr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt, sig b

corr coef poptotal pctpopfemale pctpopmale pctpopunder14 pctpop15to24 pctpop25to44 pctpop45to64 pctpopover65 pctpopover18 pctlatinx pctwhite pctblack pctasian pctpacific pctamericanindian unemployment statemin employed unemployed afdc_case afdc_rep afdccases_childonly marginallyfoodinsecure foodinsecure verylowfoodsecure foodstamp_case foodstamp_rep nslp_free nslp_reduced nslp_total sbp_free sbp_reduced sbp_total povrate ssirecipients_aged ssirecipients_blind ssirecipients_disabled ssirecipients_total stateeitcrate wicparticipation workerscompensation gunbckcheck employer_tot_pct employer_female_pct uninsured_tot_pct uninsured_female_pct medicaid_tot_pct medicaid_female_pct lowincchildren_number abor_optout_inst abor_pubfund bus_energy_consum bus_energy_consum_pc cons_fossil cons_renewable res_energy_price energy_efficiency_rank energy_efficiency_score dem_governor dem_vote_2016_nyt

   // COPY INTO SPREADSHEET "correlations elected.csv"
   // go to "Audit the Public Figures Replication File.R" to create Figure 

   
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S16  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
 
 *Public
 use "analytic sample public and elected BOTH WAVES.dta", clear

 reg finished_survey blacktr if elected==0, absorb(unique)
  regsave blacktr using "effects_on_survey_completion_public_elected.dta", detail(all) addlabel(group, Public) replace 

  sum finished_survey if blacktr==0 & e(sample)==1 
 
 disp  -.00074/.007812 // -.09472606

 *Elected Officials
 use "analytic sample public and elected BOTH WAVES.dta", clear

 reg finished_survey blacktr if elected==1, absorb(unique)
 regsave blacktr using "effects_on_survey_completion_public_elected.dta", detail(all) addlabel(group, Elected) append 

  sum finished_survey if blacktr==0 & e(sample)==1 

 disp   -.0016045 / .0214212  // -.07490243

use "effects_on_survey_completion_public_elected.dta", clear
 
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.007812 if group=="Public"
replace coef_base=coef/.0214212  if group=="Elected"

replace stderr_base=stderr/.007812 if group=="Public"
replace stderr_base=stderr/.0214212  if group=="Elected"

gen model_num=.
replace model_num=1 in 1
replace model_num=2 in 2

saveold "effects_on_survey_completion_public_elected_cleaned.dta", replace version(12)
   
     // go to "Audit the Public Figures Replication File.R" to create Figure  
   
 ****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S16  ************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
   
 use "analytic sample public and elected BOTH WAVES.dta", clear
 
 rename state state_abbrev
 
 merge m:1 state_abbrev using "state populations.dta"
 
 reghdfe  responded blacktr if elected==0 [pweight=state_population_prop], absorb(unique_id_pooled)
 sum responded if blacktr==0 & e(sample)==1 //  .016028
  regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, pooled) replace 

 reghdfe  responded blacktr if white==1 & elected==0 [pweight=state_population_prop], absorb(unique_id_pooled) 
  sum responded if blacktr==0 & e(sample)==1 //  .0175594 
regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, white) append 

 reghdfe  responded blacktr if black==1 & elected==0 [pweight=state_population_prop], absorb(unique_id_pooled) 
   sum responded if blacktr==0 & e(sample)==1 //  .009906  
   regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, black) append 

 reghdfe  responded blacktr if asian==1 & elected==0 [pweight=state_population_prop], absorb(unique_id_pooled) 
    sum responded if blacktr==0 & e(sample)==1 //  .0128277
   regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, asian) append 

 reghdfe  responded blacktr if hispanic==1 & elected==0 [pweight=state_population_prop], absorb(unique_id_pooled)
     sum responded if blacktr==0 & e(sample)==1 // .0121604 
   regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, hispanic) append 

 reghdfe  responded blacktr if white==0 & black==0 & elected==0 [pweight=state_population_prop], absorb(unique_id_pooled)
      sum responded if blacktr==0 & e(sample)==1 //  .0138406 
    regsave blacktr using "population_weights.dta", detail(all) addlabel(subgroup, other) append 
	
use "population_weights.dta", clear
	
capture drop coef_base stderr_base model_num
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.016028 if subgroup=="pooled"
replace coef_base=coef/.0175594 if subgroup=="white"
replace coef_base=coef/.009906 if subgroup=="black"
replace coef_base=coef/.0128277 if subgroup=="asian"
replace coef_base=coef/.0121604  if subgroup=="hispanic"
replace coef_base=coef/.0138406 if subgroup=="other"

replace stderr_base=stderr/.016028 if subgroup=="pooled"
replace stderr_base=stderr/.0175594 if subgroup=="white"
replace stderr_base=stderr/.009906 if subgroup=="black"
replace stderr_base=stderr/.0128277 if subgroup=="asian"
replace stderr_base=stderr/.0121604  if subgroup=="hispanic"
replace stderr_base=stderr/.0138406 if subgroup=="other"

gen model_num=_n

saveold "population_weights.dta", version(12) replace
  
      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

   
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S18 *************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
   
   //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S19/S20 *********************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
    
 use "analytic sample public and elected BOTH WAVES.dta", clear

	 *Individual FE are slightly more precise than block FE
     areg  responded blacktr if elected_official==0, absorb(unique_id_pooled)
     reg  responded blacktr ibn.state_encode asian black hispanic white if elected_official==0, nocon baselevels
	   regsave blacktr using "overall_effects_concordance_block_vars.dta", detail(all) addlabel(group, Public) replace 
     reg  responded blacktr ibn.south asian black hispanic white if elected_official==0, nocon baselevels
	 regsave blacktr using "overall_effects_concordance_block_vars_south.dta", detail(all) addlabel(group, Public) replace 
	sum responded if blacktr==0 & e(sample)==1 & elected_official==0

 reghdfe  responded blacktr if elected_official==1, absorb(unique_id_pooled)
 regsave blacktr using "overall_effects_concordance.dta", detail(all) addlabel(group, Elected Officials) append 
 	sum responded if blacktr==0 & e(sample)==1 & elected_official==1

	*Individual FE are slightly more precise than block FE
     areg  responded blacktr if elected_official==1, absorb(unique_id_pooled)
     reg  responded blacktr ibn.state_encode  asian black hispanic white if elected_official==1, nocon baselevels
	regsave blacktr using "overall_effects_concordance_block_vars.dta", detail(all) addlabel(group, Elected Officials) append 
 reg  responded blacktr ibn.south asian black hispanic white if elected_official==1, nocon baselevels
	 regsave blacktr using "overall_effects_concordance_block_vars_south.dta", detail(all) addlabel(group, Elected Officials) append 
	sum responded if blacktr==0 & e(sample)==1 & elected_official==1
	  
**** Scaling and exporting	 
	 
  use "overall_effects_concordance_block_vars.dta", clear
  
 capture drop  coef_base stderr_base
 gen coef_base=.
  gen stderr_base=.

 replace coef_base=coef/.016028 if group=="Public"
  replace stderr_base=stderr/.016028 if group=="Public"

  replace coef_base=coef/.0415679 if group=="Elected Officials"
  replace stderr_base=stderr/.0415679 if group=="Elected Officials"
  
    capture drop model_num
  gen model_num=_n
  
    saveold "overall_effects_concordance_block_vars.dta", replace version(12)

	
use	"overall_effects_concordance_block_vars_south.dta", clear
	
 capture drop  coef_base stderr_base
 gen coef_base=.
  gen stderr_base=.

 replace coef_base=coef/.016028   if group=="Public"
  replace stderr_base=stderr/.016028 if group=="Public"

  replace coef_base=coef/ .0416348 if group=="Elected Officials"
  replace stderr_base=stderr/ .0416348 if group=="Elected Officials"
  
    capture drop model_num
  gen model_num=_n
  
   saveold	"overall_effects_concordance_block_vars_south.dta", version(12) replace

	 
	 
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*************************************** FIGURE S21/S23 - Made in R *********************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

// We cannot share the data for these figures, because they includes latitude/longitude codes for the individuals in our sample. We have signed data use agreements that prohibit us from sharing this identifiable data. As stated in our data availability statement provided to the journal at the time of the first submission, we cannot share identifying information.
// That said, see "Audit the Public Figures Replication File.R" for the code that made this figure   
   
   
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S24, S25, S26 **************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

  *Public
 use "analytic sample public and elected BOTH WAVES.dta", clear
 
 	reghdfe  responded blacktr if state~="AK" & elected==0, absorb(unique_id_pooled) 
	sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "iteratively_leave_state_out.dta", detail(all) addlabel(state, AK, base_rate, r(mean)) replace 

 levelsof state, local(statelevels)
foreach var of local statelevels{
	di "`var'"
	reghdfe  responded blacktr if state~="`var'" & elected==0, absorb(unique_id_pooled) 
		sum responded if blacktr==0 & e(sample)==1
	regsave blacktr using "iteratively_leave_state_out.dta", detail(all) addlabel(state, `var', base_rate, `r(mean)') append 
}
 
use "iteratively_leave_state_out.dta", clear
 
 gen num=_n
 drop if num==51

 capture drop coef_base stderr_base
 gen coef_base=.
 gen stderr_base=.
 
 replace coef_base=coef/base_rate
   replace stderr_base=stderr/base_rate
   
saveold "iteratively_leave_state_out.dta", version(12) replace
   
***** Elected Officials
 use "analytic sample public and elected BOTH WAVES.dta", clear

 	reghdfe  responded blacktr if state~="AK" & elected==1, absorb(unique_id_pooled) 
	sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "iteratively_leave_state_out_elected.dta", detail(all) addlabel(state, AK, base_rate, r(mean)) replace 

 
 levelsof state, local(statelevels)
foreach var of local statelevels{
	di "`var'"
	reghdfe  responded blacktr if state~="`var'" & elected==1, absorb(unique_id_pooled) 
		sum responded if blacktr==0 & e(sample)==1
	regsave blacktr using "iteratively_leave_state_out_elected.dta", detail(all) addlabel(state, `var', base_rate, `r(mean)') append 
}
 
use "iteratively_leave_state_out_elected.dta", clear
 
 gen num=_n
 drop if num==51

 capture drop coef_base stderr_base
 gen coef_base=.
 gen stderr_base=.
 
 replace coef_base=coef/base_rate
   replace stderr_base=stderr/base_rate
   
saveold "iteratively_leave_state_out_elected.dta", version(12) replace

***** Difference/Interaction
 use "analytic sample public and elected BOTH WAVES.dta", clear

 reg  responded blacktr##elected_official   ibn.state_encode asian black hispanic white if state~="AK"
 sum responded if blacktr==0 & e(sample)==1
regsave 1.blacktr#1.elected_official using "iteratively_leave_state_out_interaction.dta", detail(all) addlabel(state, AK, base_rate, r(mean)) replace 

 levelsof state, local(statelevels)
foreach var of local statelevels{
	di "`var'"
	reg  responded blacktr##elected_official ibn.state_encode asian black hispanic white  if state~="`var'"
		sum responded if blacktr==0 & e(sample)==1
	regsave 1.blacktr#1.elected_official using "iteratively_leave_state_out_interaction.dta", detail(all) addlabel(state, `var', base_rate, `r(mean)') append 
}
 
use "iteratively_leave_state_out_interaction.dta", clear
 
 gen num=_n
 drop if num==51

 capture drop coef_base stderr_base
 gen coef_base=.
 gen stderr_base=.
 
 replace coef_base=coef/base_rate
   replace stderr_base=stderr/base_rate
   
saveold "iteratively_leave_state_out_interaction.dta", version(12) replace
 
      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S27 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

 use "analytic sample public and elected BOTH WAVES.dta", clear

 areg  responded blacktr if elected==1, absorb(unique_id_pooled)
 sum responded if blacktr==0 & e(sample)==1
 regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Pooled Sample) replace 

 areg  responded blacktr if white==1 & elected==1, absorb(unique_id_pooled)
  sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Whites) append 

 areg  responded blacktr if black==1 & elected==1, absorb(unique_id_pooled) // 
   sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Blacks) append

 areg  responded blacktr if asian==1 & elected==1, absorb(unique_id_pooled) // 
   sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Asians) append

 areg  responded blacktr if hispanic==1 & elected==1, absorb(unique_id_pooled) // 
  sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Hispanics) append

 areg  responded blacktr if white==0 & black==0 & elected==1, absorb(unique_id_pooled) // 
  sum responded if blacktr==0 & e(sample)==1
regsave blacktr using "overall_effects_by_recipient_race_elected_officials.dta", detail(all) addlabel(group, Hispanics & Asians) append	 
  
 use "overall_effects_by_recipient_race_elected_officials.dta", clear
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.0416359  if group=="Pooled Sample"
replace coef_base=coef/.0424493  if group=="Whites"
replace coef_base=coef/ .0352811   if group=="Blacks"
replace coef_base=coef/ .0285714  if group=="Asians"
replace coef_base=coef/.0297845  if group=="Hispanics"
replace coef_base=coef/.0292804  if group=="Hispanics & Asians"

replace stderr_base=stderr/.0416359 if group=="Pooled Sample"
replace stderr_base=stderr/.0424493   if group=="Whites"
replace stderr_base=stderr/.0352811   if group=="Blacks"
replace stderr_base=stderr/.0285714 if group=="Asians"
replace stderr_base=stderr/.0297845 if group=="Hispanics"
replace stderr_base=stderr/.0292804  if group=="Hispanics & Asians"

replace group="Hispanics, Asians, Other" if group=="Hispanics & Asians"

gen model_num=.
replace model_num=1 in 6
replace model_num=2 in 5
replace model_num=3 in 4
replace model_num=4 in 3
replace model_num=5 in 2
replace model_num=6 in 1

saveold "overall_effects_by_recipient_race_elected_officials_old.dta", replace version(12)

    //  see "Audit the Public Figures Replication File.R" for the code that made this figure   


****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S28 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "analytic sample public with party BOTH WAVES.dta", clear

   areg  responded blacktr##white if modeled_democrat==1 & race=="Black" | race=="White" & elected==0, absorb(state_encode)   // White D's v. Black D's
 sum responded if blacktr==0 & e(sample)==1 //   .0168889 
 regsave 1.blacktr#1.white using "race_by_party.dta", detail(all) addlabel(subgroup, Democrats) replace 
 
 areg  responded blacktr##white if modeled_republican==1 & race=="Black" | race=="White"  & elected==0, absorb(state_encode)   // White R's v. Black R's 
  sum responded if blacktr==0 & e(sample)==1 //  .0175823 
 regsave 1.blacktr#1.white using "race_by_party.dta", detail(all) addlabel(subgroup, Republicans) append 

  areg  responded blacktr##white if modeled_independent==1 & race=="Black" | race=="White"  & elected==0, absorb(state_encode)   // White I's v. Black I's 
   sum responded if blacktr==0 & e(sample)==1 //  .0170888 
 regsave 1.blacktr#1.white using "race_by_party.dta", detail(all) addlabel(subgroup, Independents) append 
   
******* Cleaning Results From by Party/Race
use "race_by_party.dta", clear
	
capture drop coef_base stderr_base model_num
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.0175823  if subgroup=="Republicans"
replace coef_base=coef/.0168889  if subgroup=="Democrats"
replace coef_base=coef/.0170888   if subgroup=="Independents"

replace stderr_base=stderr/.0175823   if subgroup=="Republicans"
replace stderr_base=stderr/.0168889  if subgroup=="Democrats"
replace stderr_base=stderr/.0170888   if subgroup=="Independents"

gen model_num=_n

saveold "race_by_party.dta", version(12) replace

    //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** Figure S29   **********************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

    use "analytic sample public and elected BOTH WAVES.dta", clear
 
  areg  responded blacktr if elected_official==0 & south2==1, absorb(unique_id_pooled)
  areg  responded blacktr if elected_official==0 & south2==0, absorb(unique_id_pooled)
  reg  responded blacktr##south2 asian black hispanic white i.state_encode if elected_official==0
  	sum responded if blacktr==0 & e(sample)==1
   regsave 1.blacktr#1.south2 using "effects by south.dta", detail(all) addlabel(group, Public, base_rate, `r(mean)') replace 

    areg  responded blacktr if elected_official==1 & south2==1, absorb(unique_id_pooled)
  areg  responded blacktr if elected_official==1 & south2==0, absorb(unique_id_pooled)
    reg  responded blacktr##south2 asian black hispanic white i.state_encode if elected_official==1
	sum responded if blacktr==0 & e(sample)==1
   regsave 1.blacktr#1.south2 using "effects by south.dta", detail(all) addlabel(group, Elected Officials, base_rate, `r(mean)') append 
   
   use "effects by south.dta", clear
   
 capture drop coef_base stderr_base
 gen coef_base=.
 gen stderr_base=.
 
 replace coef_base=coef/base_rate
   replace stderr_base=stderr/base_rate
   
   saveold "effects by south.dta", version(12) replace
  
      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** Figure S30   **********************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
     //  see "Audit the Public Figures Replication File.R" for the code that made this figure   
 
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** Figure S31   **********************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
  //  see "Audit the Public Figures Replication File.R" for the code that made the left pabel of thiss figure   

  *Breaking by state individually (PUBLIC Stratifying and Individual FE)
    use "analytic sample public and elected BOTH WAVES.dta", clear

areg  responded blacktr if elected_official==0 & state_encode==1, absorb(unique_id_pooled)
sum responded if blacktr==0 & e(sample)==1 & elected_official==0
regsave blacktr using "public_state_estimates.dta", detail(all) addlabel(state_encode, 1, base_rate, `r(mean)') replace 

	 tab state, gen(st_)
	 
 forvalues i = 2(1)50 {
 tab state if state_encode==`i'
  areg  responded blacktr if elected_official==0 & state_encode==`i', absorb(unique_id_pooled)
  	  	sum responded if blacktr==0 & e(sample)==1 & elected_official==0
  regsave blacktr using "public_state_estimates.dta", detail(all) addlabel(state_encode, `i', base_rate, `r(mean)') append 

 }
 
 use "public_state_estimates.dta", clear
 
 capture drop coef_base 
 capture drop stderr_base 
 capture drop  negative 
 capture drop _merge_state_abbrev
 capture drop _merge
  
 gen coef_base=coef/base_rate
 gen stderr_base=stderr/base_rate
 
 gen negative=1 if coef<0
 replace negative=0 if coef>=0 & coef~=.
 tab negative
 
  merge 1:1 state_encode using "state_numbers.dta", gen(_merge_state_abbrev)
 
drop if _merge==2
 
 order state coef
 
   statastates, a(state)
   drop if _merge==2
   drop _merge
   
   gsort - coef_base
   gen num=_n
   sum coef_base, d
   
      capture drop region
      rename state_name region
   replace region=lower(region)

  saveold "public_state_estimates.dta", version(12) replace	  
 
      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** Figure S32   **********************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
  
    use "analytic sample public and elected BOTH WAVES.dta", clear
	
	drop if elected==1
  
gen reported_race=1 if state=="AL" | state=="FL" | state=="GA" | state=="LA" | state=="NC" | state=="SC" | state=="MS" | state=="TN"
 replace reported_race=0 if reported_race==.

 reg responded blacktr##reported_race 
 reg finished_survey blacktr##reported_race 
 
 *responded
 reg  responded blacktr##reported_race  
 sum responded if blacktr==0 & e(sample)==1 // .016028
 regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, pooled) replace 

 reg  responded blacktr##reported_race  if white==1 
  sum responded if blacktr==0 & e(sample)==1 // .0175594
 regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, white) append 

 reg  responded blacktr##reported_race  if black==1 
   sum responded if blacktr==0 & e(sample)==1 // .009906 
  regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, black) append 

 reg  responded blacktr##reported_race  if asian==1 
   sum responded if blacktr==0 & e(sample)==1 // .0128277 
   regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, asian) append 

 reg  responded blacktr##reported_race  if hispanic==1 
    sum responded if blacktr==0 & e(sample)==1 // .0121604 
    regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, hispanic) append 
 
 reg  responded blacktr##reported_race  if white==0 & black==0
 sum responded if blacktr==0 & e(sample)==1 // .0138406  
 regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, responded, subgroup, other) append 

 **** finished
 reg  finished_survey blacktr##reported_race  
 sum finished_survey if blacktr==0 & e(sample)==1 // .007812  
 regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, pooled) append 

 reg  finished_survey blacktr##reported_race  if white==1 
  sum finished_survey if blacktr==0 & e(sample)==1 // .0088478 
  regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, white) append 

 reg  finished_survey blacktr##reported_race  if black==1  
   sum finished_survey if blacktr==0 & e(sample)==1 //  .0039407 
   regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, black) append 

 reg  finished_survey blacktr##reported_race  if asian==1 
   sum finished_survey if blacktr==0 & e(sample)==1 // .0064138 
    regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, asian) append 

 reg  finished_survey blacktr##reported_race  if hispanic==1 
    sum finished_survey if blacktr==0 & e(sample)==1 // .0050194 
     regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, hispanic) append 

 reg  finished_survey blacktr##reported_race  if white==0 & black==0
     sum finished_survey if blacktr==0 & e(sample)==1 // .0061707 
 regsave  1.blacktr#1.reported_race  using "reporting_states.dta", detail(all) addlabel(group, public, dv, finished, subgroup, other) append 

 
use "reporting_states.dta", clear
 
gen model_num=_n

replace subgroup="hispanic, asian, other" if subgroup=="other"

saveold "reporting_states.dta", version(12) replace

      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S33 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "analytic sample public with party BOTH WAVES.dta", clear
 
 replace agerange=trim(agerange)
 
   areg  responded blacktr if agerange=="18 - 24", absorb(state_encode)  //
   areg  responded blacktr   if agerange=="25 - 34", absorb(state_encode)  //
   areg  responded blacktr   if agerange=="35 - 44", absorb(state_encode)  //
   areg  responded blacktr  if agerange=="45 - 54", absorb(state_encode)  //
   areg  responded blacktr   if agerange=="55 - 64", absorb(state_encode)  //
   areg  responded blacktr  if agerange=="65+", absorb(state_encode)  //
   
      reg  responded blacktr  i.state_encode if agerange=="UNKNOWN"  //

   areg  responded blacktr if agerange=="18 - 24" | agerange=="25 - 34", absorb(state_encode)  //
   sum responded if blacktr==0 & e(sample)==1 // .0087695
   regsave blacktr using "results_by_age.dta", detail(all) addlabel(subgroup, 18-34) replace 

   areg  responded blacktr if agerange=="35 - 44" | agerange=="45 - 54", absorb(state_encode)  //
   sum responded if blacktr==0 & e(sample)==1 //  .0144799
   regsave blacktr using "results_by_age.dta", detail(all) addlabel(subgroup, 35-54) append 

   areg  responded blacktr if agerange=="55 - 64" | agerange=="65+", absorb(state_encode)  //
   sum responded if blacktr==0 & e(sample)==1 // .0227162 
   regsave blacktr using "results_by_age.dta", detail(all) addlabel(subgroup, 55+) append 

  use "results_by_age.dta", clear
   
 capture drop coef_base stderr_base model_num
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.0087695  if subgroup=="18-34"
replace coef_base=coef/.0144799  if subgroup=="35-54"
replace coef_base=coef/.0227162   if subgroup=="55+"

replace stderr_base=stderr/.0087695   if subgroup=="18-34"
replace stderr_base=stderr/.0144799  if subgroup=="35-54"
replace stderr_base=stderr/.0227162   if subgroup=="55+"

gen model_num=_n

saveold "results_by_age.dta", version(12) replace

 
      //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S34 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

 use "analytic sample public and elected BOTH WAVES.dta", clear

 reghdfe  responded blacktr, absorb(unique_id_pooled)
 sum responded if blacktr==0 & e(sample)==1 
 regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, Pooled) replace 

  reghdfe  responded blacktr if white==1, absorb(unique_id_pooled) 
  sum responded if blacktr==0 & e(sample)==1 
  regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, White) append 
  
  reghdfe  responded blacktr if black==1, absorb(unique_id_pooled) 
  sum responded if blacktr==0 & e(sample)==1 
  regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, black) append 
	 
  reghdfe  responded blacktr if asian==1, absorb(unique_id_pooled) 
  sum responded if blacktr==0 & e(sample)==1 
  regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, Asian) append 
	 
  reghdfe  responded blacktr if hispanic==1, absorb(unique_id_pooled) 
  sum responded if blacktr==0 & e(sample)==1 
  regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, Hispanic) append 

  reghdfe  responded blacktr if white==0 & black==0, absorb(unique_id_pooled)
   sum responded if blacktr==0 & e(sample)==1 
  regsave blacktr using "pooled_effects.dta", detail(all) addlabel(group, Pooled, race, Asian Hispanic and Others) append 

 use "pooled_effects.dta", clear
 
 capture drop  coef_base stderr_base
 gen coef_base=.
 gen stderr_base=.

 replace coef_base=coef/.0195896  if race=="Pooled"
 replace stderr_base=stderr/.0195896  if race=="Pooled"
 
 replace coef_base=coef/ .0219189   if race=="White"
 replace stderr_base=stderr/ .0219189   if race=="White"
 
 replace coef_base=coef/ .0107132   if race=="black" | race=="Black"
 replace stderr_base=stderr/ .0107132   if race=="black" | race=="Black"
 
  replace coef_base=coef/ .0137004     if race=="Asian"
 replace stderr_base=stderr/ .0137004     if race=="Asian"
 
   replace coef_base=coef/ .0134999      if race=="Hispanic"
 replace stderr_base=stderr/ .0134999      if race=="Hispanic"
 
    replace coef_base=coef/  .0144928       if race=="Asian Hispanic and Others" | race=="Asian, Hispanic, and Others"
 replace stderr_base=stderr/  .0144928       if race=="Asian Hispanic and Others" | race=="Asian, Hispanic, and Others"
 
 replace race="Asian, Hispanic, and Others" if race=="Asian Hispanic and Others"
  replace race="Black" if race=="black"
  
  capture drop model_num
  gen model_num=.
replace model_num=1 in 6
replace model_num=2 in 5
replace model_num=3 in 4
replace model_num=4 in 3
replace model_num=5 in 2
replace model_num=6 in 1

 saveold "pooled_effects.dta", version(12) replace

       //  see "Audit the Public Figures Replication File.R" for the code that made this figure   


****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S35 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

use "analytic sample public and elected with gender BOTH WAVES.dta", clear

 drop if state=="PR" | state=="DC"
 
 encode state, gen(state_encode)
 
 gen blacktr=1 if whitetrw2==0
 replace blacktr=0 if  whitetrw2==1

 reg  responded blacktr##female female_imputed asian black hispanic white i.state_encode if elected==1
 regsave 1.blacktr#1.female using "effects by gender.dta", detail(all) addlabel(group, Elected Officials) replace 
  sum responded if blacktr==0 & e(sample)==1
 
 reg  responded blacktr##female female_imputed asian black hispanic white i.state_encode if elected==0
 regsave 1.blacktr#1.female using "effects by gender.dta", detail(all) addlabel(group, Public) append 
  sum responded if blacktr==0 & e(sample)==1
 
use "effects by gender.dta", clear

capture drop coef_base stderr_base
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/ .0415679  if group=="Elected Officials"
replace coef_base=coef/ .016028   if group=="Public"

replace stderr_base=stderr/ .0415679  if group=="Elected Officials"
replace stderr_base=stderr/ .016028   if group=="Public"

saveold "effects by gender.dta", version(12) replace
	   
       //  see "Audit the Public Figures Replication File.R" for the code that made this figure   


****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S36 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

 use "analytic sample public and elected BOTH WAVES.dta", clear

drop if elected==1
 
rename unique_id_pooled dt_regid
merge m:1 dt_regid using "final_name_match_public_sample.dta", gen(_merge_name_familiar)

egen has_black_precinct_std=std(has_black_precinct), mean(0) std(1)
egen has_white_precinct_std=std(has_white_precinct), mean(0) std(1)

gen has_black_precinct_0_1=1 if has_black_precinct~=0
replace has_black_precinct_0_1=0 if has_black_precinct==0

gen has_white_precinct_0_1=1 if has_white_precinct~=0
replace has_white_precinct_0_1=0 if has_white_precinct==0

encode race, gen(race_num)
encode state, gen(state_num)

reg responded blacktr##c.has_black_precinct_std blacktr##c.has_white_precinct_std i.state_num i.race_num // continuous

	regsave  1.blacktr#c.has_black_precinct_std  1.blacktr#c.has_white_precinct_std using "differential_effects_by_familiarity.dta", detail(all) addlabel(group, Continuous Measure) replace
	
reg responded blacktr##has_black_precinct_0_1 blacktr##has_white_precinct_0_1 i.state_num i.race_num // dummy

	regsave  1.blacktr#1.has_black_precinct_0_1  1.blacktr#1.has_white_precinct_0_1 using "differential_effects_by_familiarity.dta", detail(all) addlabel(group, Dichotomous Measure) append

corr has_black_precinct_0_1  asian black hispanic white 

tab has_black_precinct_0_1
tab has_white_precinct_0_1

use "differential_effects_by_familiarity.dta", clear

replace var="Has White Name in Community" if var=="1.blacktr#1.has_white_precinct_0_1"
replace var="Has White Name in Community" if var=="1.blacktr#c.has_white_precinct_std"

replace var="Has Black Name in Community" if var=="1.blacktr#1.has_black_precinct_0_1"
replace var="Has Black Name in Community" if var=="1.blacktr#c.has_black_precinct_std"

saveold "differential_effects_by_familiarity.dta", version(12) replace
	   
       //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S37 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

***** PUBLIC

 use "analytic sample public and elected BOTH WAVES.dta", clear

 drop if elected==1
 
encode state, gen(state_num)

reg responded blacktr##wave i.state_num
sum responded if blacktr==0 & e(sample)==1 // .016028
regsave  1.blacktr#2.wave  using "differential_effects_by_wave.dta", detail(all) addlabel(group, Public, dv, responded) replace 

reg finished_survey blacktr##wave i.state_num
sum finished_survey if blacktr==0 & e(sample)==1 // .007812 
regsave 1.blacktr#2.wave using "differential_effects_by_wave.dta", detail(all) addlabel(group, Public, dv, finished) append 

***** ELECTED 
 use "analytic sample public and elected BOTH WAVES.dta", clear

 drop if elected==0
 
encode state, gen(state_num)

reg responded blacktr##wave i.state_num
sum responded if blacktr==0 & e(sample)==1 // .041569  
regsave  1.blacktr#2.wave  using "differential_effects_by_wave.dta", detail(all) addlabel(group, Elected, dv, responded) append 

reg finished_survey blacktr##wave i.state_num
sum finished_survey if blacktr==0 & e(sample)==1 //  .0213149 
regsave 1.blacktr#2.wave using "differential_effects_by_wave.dta", detail(all) addlabel(group, Elected, dv, finished) append 

***** DATA CLEANING  
use "differential_effects_by_wave.dta", clear

capture drop coef_base stderr_base model_num
gen coef_base=.
gen stderr_base=.

replace coef_base=coef/.016028 if group=="Public" & dv=="responded"
replace coef_base=coef/.041569  if group=="Elected" & dv=="responded"

replace coef_base=coef/.007812  if group=="Public" & dv=="finished"
replace coef_base=coef/.0213149  if group=="Elected" & dv=="finished"

replace stderr_base=stderr/.016028 if group=="Public" & dv=="responded"
replace stderr_base=stderr/.041569  if group=="Elected" & dv=="responded"

replace stderr_base=stderr/.007812  if group=="Public" & dv=="finished"
replace stderr_base=stderr/.0213149  if group=="Elected" & dv=="finished"

gen model_num=.
replace model_num=1 in 1
replace model_num=2 in 2
replace model_num=3 in 3
replace model_num=4 in 4

replace group="Responded (Public)" if group=="Public" & dv=="responded"
replace group="Responded (Elected)"  if group=="Elected" & dv=="responded"
replace group="Finished Survey (Public)" if group=="Public" & dv=="finished"
replace group="Finished Survey (Elected)" if group=="Elected" & dv=="finished"

saveold "differential_effects_by_wave.dta", version(12) replace

       //  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S38 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

//  see "Audit the Public Figures Replication File.R" for the code that made this figure   

****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
**************** FIGURE S39 ************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************

//  see "Audit the Public Figures Replication File.R" for the code that made this figure   

	
